cmake_minimum_required(VERSION 3.8)
project(plc_bridge)

# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 17)
endif()

# Find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(agv_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)

# Include directories
include_directories(
  include
  ${Boost_INCLUDE_DIRS}
)

# Add the executable
add_executable(plc_bridge src/plc_bridge.cpp)

# Target dependencies
ament_target_dependencies(
  plc_bridge
  rclcpp
  agv_msgs
  std_msgs
  Boost
)

# Link Boost libraries
target_link_libraries(plc_bridge
  ${Boost_LIBRARIES}
)

# Link generated messages
target_include_directories(plc_bridge PRIVATE
  ${CMAKE_CURRENT_BINARY_DIR}
)

# Install targets
install(TARGETS
  plc_bridge
  DESTINATION lib/${PROJECT_NAME}
)

install(PROGRAMS 
  script/run_simulation
  script/agv_msg_simulation.py  
  DESTINATION lib/${PROJECT_NAME}
)

# Export dependencies
ament_export_include_directories(include)
ament_export_libraries(plc_bridge)

# Ament package
ament_package()